using System;
using System.Text.Json;
using Furion.JsonSerialization;
using JsonSerializer = Newtonsoft.Json.JsonSerializer;

namespace WebSMS;

public class ResponseObject<T>
{
    public Object? Data { get; set; }
    public string? Message { get; set; }
    public ResponseResult Status { get; set; }

    public ResponseObject<T> Ok(T data, string message)
    {
        Status = ResponseResult.Success;
        Data = data;
        Message = message;
        return this;
    }
    public ResponseObject<T> Ok( string message)
    {
        Status = ResponseResult.Success;
        Message = message;
        return this;
    }
    public ResponseObject<T> Ok( T data)
    {
        Status = ResponseResult.Success;
        Data = data;
        return this;
    }
    public ResponseObject<T> Fail(T data, string message)
    {
        Status = ResponseResult.Fail;
        Data = data;
        Message = message;
        return this;
    }
    public ResponseObject<T> Fail(string message)
    {
        Status = ResponseResult.Fail;
        Message = message;
        return this;
    }
    public ResponseObject<T> Fail(T data, string message,ResponseResult result)
    {
        Status = result;
        Data = data;
        Message = message;
        return this;
    }

    public ResponseObject<T> Error(T data, string message)
    {
        Status = ResponseResult.Error;
        Data = data;
        Message = message;
        return this;
    }

    public override string ToString()
    {
        return @"{""status"":""" + Status.ToString() + @""", ""data"":" + JSON.Serialize(Data) + @", ""message"":""" +
               Message + "}";
    }
}